import request from '@/utils/request'

const api = '/dictionary/info'

export function getInfo(token) {
  return request({
    url: '/user/info',
    method: 'get',
    params: {token}
  })
}

export function page(params) {
  return request({
    url: `${api}/page`,
    method: 'get',
    params: params
  })
}

// 修改操作
// 执行新增和修改,id是给修改的时候用的，pojo就是传过来的具体数据
export function update(id, pojo) {
  if (id === null || id === '') {
    return this.save(pojo)
  } else {
    pojo.id = id
    return request({
      url: `${api}/update`,
      method: 'post',
      data: pojo
    })
  }
}

// 查找一条记录
export function findById(id) {
  return request({
    url: `${api}/find/` + id,
    method: 'get'
  })
}

// 删除数据
export function deleteById(id) {
  return request({
    url: `${api}/delete/` + id,
    method: 'post',
    data: id
  })
}
